<?php 
require_once('inc/db_access.inc');
require_once('inc/utils.inc');

session_start();
$user = $_REQUEST['user_name'];

if($user){
	$dbc = new DBConnection();
	$dbc->getNewConnection();
	$query = "select user_id from users where name = '$user'";
	$result = $dbc->execute_query($query);
	if($result)
		$row = mysql_fetch_array($result);
	$uid = '';
	if($row){
		$uid = $row['user_id'];
	} else {
		$uid = rand_str();
		$query ="insert into users(user_id, name) values('$uid' , '$user')";
		$dbc->execute_query($query);
	}
	
	
	$_SESSION['uid'] = $uid;
	header("location: walls.php");
	$dbc->close();
}
?>
<html>
<head>
</head>
<body>
<form method='post' action='index.php' >
User Name : <input name='user_name' > 
</form>
</body>
</html>
